#include <sys/types.h>
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <error.h>
#include <stdlib.h>
int main()
{
    int n_r,n_w;
    char buffer[1024]={0};
    int fp1=open("./a.txt",O_RDONLY);
    int fp2=open("./b.txt",O_RDWR|O_CREAT|O_APPEND,0777);
    while(n_r=read(fp1,buffer,sizeof(buffer))!=0)
    {
        write(fp2,buffer,strlen(buffer));       

        
        memset(buffer,0,sizeof(buffer));
    }
    close(fp1);
    close(fp2);
    return 0;
}